package cn.bytecollege.user.controller;

import cn.bytecollege.common.entity.Address;
import cn.bytecollege.common.entity.User;
import cn.bytecollege.user.service.AddressService;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
import java.io.IOException;
import java.util.List;

@WebServlet(name = "AddressListFindController",value="/addAddress")
public class AddressListFindController extends HttpServlet {
    private AddressService addressService=null;
    public AddressListFindController(){
        addressService=new AddressService();
    }
    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
    }

    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        HttpSession session= request.getSession();
        User user=(User) session.getAttribute("user");
        List<Address> lists=addressService.findlistById(user.getUserId());
        request.setAttribute("lists",lists);
        request.getRequestDispatcher("/addAddress.jsp").forward(request,response);
    }
}
